home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
tables
/
table.frm
< prev
next >
Wrap
Text File
|
1995-09-06
|
7KB
|
220 lines
VERSION 2.00
Begin Form Form1
BackColor = &H00FFFF00&
BorderStyle = 3 'Fixed Double
Caption = "MarkUps R Us"
ClientHeight = 2880
ClientLeft = 1605
ClientTop = 1740
ClientWidth = 6225
Height = 3285
Left = 1545
LinkMode = 1 'Source
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2880
ScaleWidth = 6225
Top = 1395
Width = 6345
Begin VScrollBar VScroll1
Height = 2055
Left = 5640
TabIndex = 4
Top = 480
Width = 255
End
Begin Label Label5
Alignment = 1 'Right Justify
BorderStyle = 1 'Fixed Single
Caption = "InStock"
Height = 2055
Left = 4680
TabIndex = 10
Top = 480
Width = 975
End
Begin Label Label4
Alignment = 1 'Right Justify
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Caption = "Price"
ForeColor = &H00FF0000&
Height = 2055
Left = 3720
TabIndex = 3
Top = 480
Width = 975
End
Begin Label Label3
Alignment = 1 'Right Justify
BorderStyle = 1 'Fixed Single
Caption = "MarkUp"
Height = 2055
Left = 2760
TabIndex = 2
Top = 480
Width = 975
End
Begin Label Label2
Alignment = 1 'Right Justify
BorderStyle = 1 'Fixed Single
Caption = "Cost"
Height = 2055
Left = 1800
TabIndex = 1
Top = 480
Width = 975
End
Begin Label Label1
BorderStyle = 1 'Fixed Single
Caption = "ProdName"
Height = 2055
Left = 360
TabIndex = 0
Top = 480
Width = 1455
End
Begin Label Label10
Alignment = 2 'Center
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Caption = "In Stock"
Height = 255
Left = 4680
TabIndex = 9
Top = 240
Width = 975
End
Begin Label Label9
Alignment = 2 'Center
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Caption = "Price"
Height = 255
Left = 3720
TabIndex = 8
Top = 240
Width = 975
End
Begin Label Label8
Alignment = 2 'Center
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Caption = "MarkUp"
Height = 255
Left = 2760
TabIndex = 7
Top = 240
Width = 975
End
Begin Label Label7
Alignment = 2 'Center
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Caption = "Cost"
Height = 255
Left = 1800
TabIndex = 6
Top = 240
Width = 975
End
Begin Label Label6
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Caption = "Product Name"
Height = 255
Left = 360
TabIndex = 5
Top = 240
Width = 1455
End
End
'---------------------------------------------------------
' This is the routine that creates the Captions for each
' Label Control. The captions consist of two strings for
' each line of the Label Control. The first string is the
' value that is to be displayed on a Label line. The second
' string is the End Of Line string (EOL$) which consists
' of several blank spaces to center the text in the
' middle of the label followed by a Carriage Return
' Chr$(13) and a LineFeed Chr$(10).
'
' This routine is called by the Form_Load routine and the
' VScroll1_Change routine.
'---------------------------------------------------------
'
Sub DisplayItems ()
'==> The End Of Line string.
EOL$ = " " + Chr$(13) + Chr$(10)
'==> VScroll1.Value is the index to the Item that
' is displayed as the first item in the table.
Ndx% = VScroll1.Value
'==> Build the strings for the first Item in the table.
Label1.Caption = Item(Ndx%).ProdName
Label2.Caption = Format$(Item(Ndx%).Cost, "0.00")
Label3.Caption = Format$(Item(Ndx%).MarkUp, "0.0000")
Label4.Caption = Format$(Item(Ndx%).Price, "0.00")
Label5.Caption = Format$(Item(Ndx%).InStock, "##,##0")
'==> Add the rest of the Items in the table to the
' initial strings.
For I% = Ndx% + 1 To Ndx% + TableLen - 1
Label1.Caption = Label1.Caption + EOL$ + Item(I%).ProdName
Label2.Caption = Label2.Caption + EOL$ + Format$(Item(I%).Cost, "0.00")
Label3.Caption = Label3.Caption + EOL$ + Format$(Item(I%).MarkUp, "0.0000")
Label4.Caption = Label4.Caption + EOL$ + Format$(Item(I%).Price, "0.00")
Label5.Caption = Label5.Caption + EOL$ + Format$(Item(I%).InStock, "##,##0")
Next I%
'==> Append blanks to the last Item to keep it aligned.
Label2.Caption = Label2.Caption + " "
Label3.Caption = Label3.Caption + " "
Label4.Caption = Label4.Caption + " "
Label5.Caption = Label5.Caption + " "
End Sub
Sub Form_Load ()
'==> Set the random number generator seed.
Randomize
'==> Generate random sample data.
For I% = 1 To MaxItems
Item(I%).ProdName = String$(6, 33 + I%) '=> Dummy Product name.
Item(I%).Cost = Int(Rnd * 70 + 1) '=> Cost of $1 to $70.
Item(I%).MarkUp = Rnd '=> Markup as decimal.
Item(I%).Price = Item(I%).Cost * (1 + Item(I%).MarkUp)
Item(I%).InStock = Rnd * 1500
Next I%
'==> Set the parameters for the vertical scroll bar.
VScroll1.Min = 1
VScroll1.Max = MaxItems - TableLen '=> So we don't overrun the end of the Item array.
VScroll1.SmallChange = 1
VScroll1.LargeChange = TableLen - 1 '=> We want a 1 item overlap between pages.
VScroll1.Value = VScroll1.Min
'==> Display the Items. Note that the top
' item in the table is always Item(VScroll1.Value).
Call DisplayItems
End Sub
Sub VScroll1_Change ()
'==> Display the set of Items beginning with the
' current VScroll1.Value.
Call DisplayItems
End Sub